package comms;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class CommsTestIncoming extends MIDlet {
	private static CommsTestIncoming instance;
	private TextBox textBox;
	private DatagramAgentConnection incoming;
	private AgentConnection test;
	
	public CommsTestIncoming() {
		super();
		CommsTestIncoming.instance = this;
		textBox = new TextBox("Comms Test MIDlet", "Testing...", 25, 0);
		
		/*
		 * Comms Testing instantiation.
		 */
		this.incoming = new DatagramAgentConnection(7777);
		while (true) {
			if (incoming.hasAgent())
				textBox.setString("agent present");
			//try {this.wait(10000);} catch (Exception e) {e.printStackTrace();}
		}
	}
	
	public static CommsTestIncoming getInstance() {
		return CommsTestIncoming.instance;
	}
	
	public void startApp() {
		this.display();
	}
	
	public void pauseApp() {
		
	}
	
	public void display() {
		Display.getDisplay(this).setCurrent(textBox);
	}
	
	public void destroyApp(boolean dest) {
		CommsTestIncoming.instance = null;
	}
}
